.class Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;
.super Ljava/io/OutputStream;
.source "DatagramImpl.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lorg/microemu/cldc/datagram/DatagramImpl;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = "BufferOutputStream"
.end annotation


# instance fields
.field private offset:I

.field private originalOffset:I

.field private final this$0:Lorg/microemu/cldc/datagram/DatagramImpl;


# direct methods
.method public constructor <init>(Lorg/microemu/cldc/datagram/DatagramImpl;)V
    .locals 1
    .parameter

    .prologue
    .line 73
    iput-object p1, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->this$0:Lorg/microemu/cldc/datagram/DatagramImpl;

    invoke-direct {p0}, Ljava/io/OutputStream;-><init>()V

    .line 74
    invoke-static {p1}, Lorg/microemu/cldc/datagram/DatagramImpl;->access$000(Lorg/microemu/cldc/datagram/DatagramImpl;)Ljava/net/DatagramPacket;

    move-result-object v0

    invoke-virtual {v0}, Ljava/net/DatagramPacket;->getOffset()I

    move-result v0

    iput v0, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->originalOffset:I

    .line 75
    iget v0, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->originalOffset:I

    iput v0, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->offset:I

    .line 76
    return-void
.end method


# virtual methods
.method public reset()V
    .locals 1

    .prologue
    .line 87
    iget v0, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->originalOffset:I

    iput v0, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->offset:I

    .line 88
    return-void
.end method

.method public write(I)V
    .locals 4
    .parameter "b"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 79
    iget-object v1, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->this$0:Lorg/microemu/cldc/datagram/DatagramImpl;

    invoke-static {v1}, Lorg/microemu/cldc/datagram/DatagramImpl;->access$000(Lorg/microemu/cldc/datagram/DatagramImpl;)Ljava/net/DatagramPacket;

    move-result-object v1

    invoke-virtual {v1}, Ljava/net/DatagramPacket;->getData()[B

    move-result-object v0

    .line 80
    .local v0, buffer:[B
    iget v1, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->offset:I

    array-length v2, v0

    const/4 v3, 0x1

    sub-int/2addr v2, v3

    if-ne v1, v2, :cond_0

    .line 81
    new-instance v1, Ljava/nio/BufferOverflowException;

    invoke-direct {v1}, Ljava/nio/BufferOverflowException;-><init>()V

    throw v1

    .line 83
    :cond_0
    iget v1, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->offset:I

    add-int/lit8 v2, v1, 0x1

    iput v2, p0, Lorg/microemu/cldc/datagram/DatagramImpl$BufferOutputStream;->offset:I

    int-to-byte v2, p1

    aput-byte v2, v0, v1

    .line 84
    return-void
.end method
